package disenio

import modelo.Jugador
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.widgets.Label
import modelo.Zombie
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.bindings.ObservableProperty
import org.uqbar.arena.bindings.PropertyAdapter
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.tables.Table
import org.uqbar.arena.widgets.tables.Column
import modelo.Observer

class AtacarWindow extends Dialog<Jugador> {

	new(WindowOwner owner, Jugador jugador) {
		super(owner, jugador)
	}
	override def createMainTemplate(Panel mainPanel) {
		super.createMainTemplate(mainPanel)
		//this.createFormPanel(mainPanel)
			
	}
	
	override protected createFormPanel(Panel mainPanel) {
		val form = new Panel(mainPanel)
		form.layout = new ColumnLayout(2)
		new Label(form).text = "Elija un zombie"
		val selectorZombie = new Selector<Zombie>(form)
		selectorZombie.allowNull(false)
		selectorZombie.bindValueToProperty("zombieSeleccionado")
		var propiedadModelos = selectorZombie.bindItemsToProperty("sistemaBase.zombiesDisponibles")
		propiedadModelos.adapter = new PropertyAdapter(typeof(Zombie), "nombre")
	    
	    
	    new Label(form).text = "Mensaje 4:"
		val labelmsj4 = new Label(form)
		labelmsj4.setWidth(500)
		labelmsj4.bindValueToProperty("obs.msj4")
		new Label(form).text = "Mensaje 3:"
		val labelmsj3 = new Label(form)
		labelmsj3.setWidth(500)
		new Label(form).text = "Mensaje 2:"
		val labelmsj2 = new Label(form)
		labelmsj2.setWidth(500)
		labelmsj2.bindValueToProperty("obs.msj2")
		labelmsj3.bindValueToProperty("obs.msj3")
		new Label(form).text = "Mensaje 1:"
		val labelmsj1 = new Label(form)
		labelmsj1.setWidth(500)
		labelmsj1.bindValueToProperty("obs.msj1")
		
		}
	
	override protected void addActions(Panel actions) {
		new Button(actions)
			.setCaption("Atacar")
			.onClick [|this.atacar]
			.setAsDefault.disableOnError

		new Button(actions) //
			.setCaption("Cancelar")
			.onClick [|this.cancel]
	}
	
	def atacar() {
		modelObject.primerAtaque
		//this.accept
	}
	
}